from jili.calc import calcor_base
from scipy.stats import percentileofscore
import pandas as pd
class fenweishu(calcor_base):
    def __init__(self,ta_arg={}):
        self.out = ["percent"]
        self.input = ["close"]
        self.parameters = {"timeperiod":20}
        super().__init__(ta_arg)
        self.batch=self.parameters["timeperiod"]
        self.lookback=self.batch-1
    def calc(self):
        percentile=None
        data=self.hisbars[self.input[0]]
        if not pd.isna(data[0]):
            percentile = percentileofscore(data, data[-1])
        return percentile
